package jdbc.statement;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:学习Statement
 * User:22954
 * Date:2024-05-12
 * Time:14:29
 */
public class Statement_ {

    public static void main(String[] args) throws IOException, SQLException {
        Properties properties = new Properties();
        properties.load(new FileInputStream("src/jdbc/mysql.properties"));
        String url = properties.getProperty("url");
        String user = properties.getProperty("user");
        String password = properties.getProperty("password");
        Connection connection = DriverManager.getConnection(url, user, password);
        Statement statement = connection.createStatement();
        Scanner scanner = new Scanner(System.in);
        String admin_name = scanner.nextLine();
        String admin_password = scanner.nextLine();
        String sql = "select * from `admin` where `name` = '" + admin_name + "' and `password` = '" + admin_password + "'";
        /*
        1' or
        or '1' = '1
         */
        ResultSet resultSet = statement.executeQuery(sql);
        if(resultSet.next()){
            System.out.println("Success load");
        } else {
            System.out.println("Failed");
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}
